//
//  POSUIEngine.m
//  HPZZTong
//
//  Created by WenJun on 14-7-18.
//  Copyright (c) 2014年 Handpay. All rights reserved.
//

#import "POSUIEngine.h"
//#import "HPUIEngine.h"
//#import "ZZTongUIEngine.h"
//#import "Utility.h"
//#import "HPSelectView.h"

static POSUIEngine * instance = nil;

@interface POSUIEngine ()

//@property(nonatomic, strong) HPSelectView* selectView;

@end

@implementation POSUIEngine

+ (id)sharedInstance
{
    if (!instance)
    {
        instance = [[super alloc] init];
    }
    return instance;
}

//- (void)notifySwipe:(id)process
//{
//    [HPUIENG showScreen:SCR_SWIPER];
//}

//- (void)notifyInputPin:(id)process appInput:(BOOL)appInput
//{
//    if (!appInput)
//    {
//        [HPUIENG showScreen:SCR_INPUT_PWD];
//    }
//    else
//    {
//        NSDictionary * params = nil;
//        if ([SwiperService.currentProcess plainAmount].length == 0)
//        {
//            params = @{@"delegate":self};
//        }
//        else
//        {
//            params = @{@"delegate":self,@"amount":[Utility getFormatMoneyAndSymbol:SwiperService.currentProcess.plainAmount]};
//        }
//        [HPUIENG showScreen:SCR_INPUT_PASSWORD params:params];
//    }
//}

- (void)inputCancel
{
//    [SwiperService.currentProcess dealResult:[HPSwiperResult failResultWithCode:HPSwiperResultCancel]];
}

//- (void)inputOver:(NSString *)pwd
//{
//    [HPUIENG showWaiting:@"请稍候..."];
//    [SwiperService.currentProcess pinInputed:pwd];
//}

//- (void)notifyReSwipe:(id)process result:(HPSwiperResult *)result
//{
//    if (_selectView) {
//        [_selectView removeFromSuperview];
//        _selectView = nil;
//    }
//    AlertCommandData* commandCancel = [[AlertCommandData alloc] initCommand:@"取消" function:@selector(swiperCancel)];
//    AlertCommandData* commandRedo = [[AlertCommandData alloc] initCommand:@"重刷" function:@selector(reSwipe)];
//    
//    NSString * msg = @"刷（插）卡失败，请重新刷（插）卡，若读取IC卡，交易完成前请勿拔出卡槽。";
//    if (result.code == HPSwiperResultDownGrage)
//    {
//        msg = TipsICCantSwipe;
//    }
//    AlertData* alertData = [[AlertData alloc] initAlertData:self title:@"提示" message:msg commands:commandRedo,commandCancel, nil];
//    [HPUIENG showAlertWithData:alertData];
//}

//- (void)swiperCancel
//{
//    [HPUIENG popScreen];
//    [SwiperService.currentProcess clear];
//}

//- (void)reSwipe
//{
//    [SwiperService.currentProcess reSwipe];
//}

- (void)processSelectApp:(NSArray *)array
{
//    if (array == nil || array.count == 0) {
//        [HPUIENG showAlert:@"此IC卡不支持该业务，请更换其它银行卡再尝试！"];
//        [SWIPERENG.currentProcess.currentSwiper cancelSwiper];
//        [HPUIENG popScreen];
//    }else if(array.count == 1){
//        NSArray* type = [array objectAtIndex:0];
//        [SwiperService doSelectApp:type complete:nil];
//    }else{
//        _selectView = [[HPSelectView alloc]initWithData:array frame:CGRectMake(20, 30, 280, 100) delegate:self];
//    }
}

+ (void)processFailed:(POSProcess *)process result:(HPSwiperResult *)result
{
//    if (result.code == HPSwiperResultNotConnected) {
//        return;
//    }
//    if (result.isCanceld || process.currentAction == SwipeActionInputPin || process.currentAction == SwipeActionEncrypt) {
//        [HPUIENG popScreen];
//    }
//    if (result.code == HPSwiperResultLowBattery) {
//        [HPUIENG showAlert:TipsLowBattery];
//        
//    }else{
//        if (result.isCanceld)
//        {
//            [HPUIENG showAlert:TipsCancel];
//        }
//        else if (process.currentAction == SwipeActionInputPin)
//        {
//            [HPUIENG showAlert:TipsInputPwdErr];
//        }
//        else if (process.currentAction == SwipeActionEncrypt)
//        {
//            [HPUIENG showAlert:TipsEncryptErr];
//        }
//    }
}

- (void)selectResult:(NSArray *)cardType{
//    [SwiperService doSelectApp:cardType complete:nil];
}
@end
